{{ header }}
{% set theme_options = registry.get('theme_options') %}
{% set config = registry.get('config') %}
{% set background_status = constant('false') %}
{% include 'fastor/template/new_elements/wrapper_top.twig' %}

<div id="mfilter-content-container">
  {% if (thumb or description) %}
  <div class="category-info clearfix">
    {% if (thumb) %}
      <div class="image"><img src="{{ thumb }}" alt="{{ heading_title }}" /></div>
    {% endif %}
    {% if (description) %}
      {{ description }}
    {% endif %}
  </div>
  {% endif %}
  {% if (categories and theme_options.get('refine_search_style') != '2') %}
  <div class="refine_search_overflow text-center"><h2 class="refine_search">{{ text_refine }}</h2></div>
  <div class="category-list{% if (theme_options.get('refine_search_style') == '1') %} {{ ' category-list-text-only' }} {% endif %}">
    <div class="row">

   {% set class = 3 %}
   {% set row = 4 %}

   {% if (theme_options.get( 'refine_search_number' ) == 2) %} {% set class = 62 %} {% endif %}
   {% if (theme_options.get( 'refine_search_number' ) == 5) %} {% set class = 25 %} {% endif %}
   {% if (theme_options.get( 'refine_search_number' ) == 3) %} {% set class = 4 %} {% endif %}
   {% if (theme_options.get( 'refine_search_number' ) == 6) %} {% set class = 2 %} {% endif %}

   {% if (theme_options.get( 'refine_search_number' ) > 1) %} {% set row = theme_options.get( 'refine_search_number' ) %} {% endif %}

    {% set row_fluid = 0 %} {% for category in theme_options.refineSearch() %} {% set row_fluid = row_fluid + 1 %}

    {% if (theme_options.get('refine_search_style') != '1') %}
      {% set width = 250 %}
      {% set height = 250 %}
      {% if (theme_options.get( 'refine_image_width' ) > 20) %} {% set width = theme_options.get( 'refine_image_width' ) %}{% endif %}
      {% if (theme_options.get( 'refine_image_height' ) > 20) %} {% set height = theme_options.get( 'refine_image_height' ) %}{% endif %}
      {% set model_tool_image = registry.get('model_tool_image') %}
      {% if (category['thumb'] != '') %}
        {% set image = model_tool_image.resize(category['thumb'], width, height) %}
      {% else %}
        {% set image = model_tool_image.resize('no_image.jpg', width, height) %}
      {% endif %}
    {% endif %}

      {% set r=row_fluid-(row_fluid/row)|round(0, 'floor')*row %} {% if (row_fluid>row and r == 1) %} {{ '</div><div class="row">' }} {% endif %}
      <div class="col-sm-{{ class }} col-xs-6">
        {% if (theme_options.get('refine_search_style') != '1') %}
        <a href="{{ category['href'] }}"><img src="{{ image }}" alt="{{ category['name'] }}" /></a>
        {% endif %}
        <a href="{{ category['href'] }}">{{ category['name'] }}</a>
      </div>
    {% endfor %}
  </div>
  </div>
  {% endif %}
  {% if (products) %}
  {% set currently = theme_options.getCurrently() %}

  <!-- Products grid -->

  {% set class = 3 %}
  {% set row = 4 %}

  {% if (theme_options.get( 'product_per_pow2' ) == 6) %} {% set class = 2 %} {% endif %}
  {% if (theme_options.get( 'product_per_pow2' ) == 5) %} {% set class = 25 %} {% endif %}
  {% if (theme_options.get( 'product_per_pow2' ) == 3) %} {% set class = 4 %} {% endif %}

  {% if (theme_options.get( 'product_per_pow2' ) > 1) %} {% set row = theme_options.get( 'product_per_pow2' ) %} {% endif %}

  <div class="product-grid active">
    <div class="row">
      {% set row_fluid = 0 %} {% for product in products %} {% set row_fluid = row_fluid + 1 %}
        {% set r=row_fluid-(row_fluid/row)|round(0, 'floor')*row %} {% if (row_fluid>row and r == 1) %} {{ '</div><div class="row">' }} {% endif %}
        <div class="col-sm-{{ class }} col-xs-6">
          {% include 'fastor/template/new_elements/product.twig' %}
        </div>
      {% endfor %}
    </div>
  </div>

  <div class="row pagination-results">
    <div class="col-sm-6 text-left">{{ pagination }}</div>
    <div class="col-sm-6 text-right">{{ results }}</div>
  </div>
  {% endif %}
  {% if (not categories and not products) %}
  <p style="padding-top: 30px">{{ text_empty }}</p>
  <div class="buttons">
    <div class="pull-right"><a href="{{ continue }}" class="btn btn-primary">{{ button_continue }}</a></div>
  </div>
  {% endif %}
</div>

{% include 'fastor/template/new_elements/wrapper_bottom.twig' %}
{% if structured_data is defined %}
  {{ structured_data|raw }}
{% endif %}
{{ footer }}
